package com.mobileseed.weather.data;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

import android.util.Log;

public class HttpClientConnector {
	private static final String TAG = "HttpClientConnection";

	public static String getStringByUrl(String url) {
		String outputString = "";
		DefaultHttpClient httpClient = new DefaultHttpClient();
		HttpGet httpGet = new HttpGet(url);
		ResponseHandler<String> responseHandler = new BasicResponseHandler();
		try {
			outputString = httpClient.execute(httpGet, responseHandler);
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			Log.i(TAG, "连接成功");
			e.printStackTrace();
		} catch (IOException e) {
			Log.i(TAG, "连接失败");
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		httpClient.getConnectionManager().shutdown();
		return outputString;
	}
}
